<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>show.js</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../../../../css/github.css" type="text/css" media="screen" />
<script src="../../../../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>
    <div class="banner">
        
        <h1>
            show.js
        </h1>
        <ul class="files">
            
            <li>
                lib/assets/javascripts/setting_app/zuzhi/show.js
                
            </li>
            <li>Last modified: 2017-02-15 16:12:36 +0800</li>
        </ul>
    </div>

    <div id="bodyContent">
        <div id="content">
  
    <div class="description">
      
<p>jQuery(function($){</p>

<pre><code>// 点击添加部门显示
$(&quot;i#js-add-department&quot;).on(&quot;click&quot;, function(){
  $(&quot;ul#depart_root&quot;).append($(&quot;li.new_department_tem&quot;))
  $(&quot;input.new-department-name&quot;).val(&quot;&quot;);
  $(&quot;li.new_department_tem&quot;).show();
})

// 点击部门的保存，进行创建
$(&quot;i.js_create_department&quot;).on(&quot;click&quot;, function(){
  var _this = this
  var department_tem = JST[&#39;settings/store_departments/item&#39;]
  var name = $(&quot;input.new-department-name&quot;).val();
  var csrf = $(&quot;input#js-settings-zuzhi-index&quot;).val();
  $.ajax({
    url: &quot;/api/store_departments&quot;,
    method: &quot;post&quot;,
    data: {name: name},
    headers: {
      &#39;X-CSRF-Token&#39;: csrf
    },
    success: function(data){
      if(data.status){
        $(&quot;li.new_department_tem&quot;).hide();
        $(&quot;ul#depart_root&quot;).append(department_tem(data.department))
      }else {
        showErrorView(data.message);
      }
    }
  })
}); //end create department

// start to unuse department
$(document).on(&quot;click&quot;, &#39;i.fa-times.js-to-remove-department&#39;, function(){
  var _this = this
  BootstrapDialog.show({
          title: &#39;提示：&#39;,
          message: &quot;确定移除此部门吗&quot;,
          cssClass: &#39;add-to-items-dialog&#39;,
          buttons: [
            {
              label: &#39;取消&#39;,
              cssClass: &#39;&#39;,
              action: function(dialog){
                  dialog.close();
              }
            },
            {
                label: &#39;确定&#39;,
                cssClass: &#39;btn-primary&#39;,
                action: function(dialog){
                    var id = $(_this).parent().data(&quot;id&quot;);
                    var csrf = $(&quot;input#js-settings-zuzhi-index&quot;).val();
                                              $.ajax({
                                                      url: &quot;/api/store_departments/&quot;+ id +&quot;/unuse&quot;,
                                                      method: &quot;put&quot;,
                                                      headers: {
                                &#39;X-CSRF-Token&#39;: csrf
                              },
                                                      success: function(data){
                                                              if(data.status == true){
                          $(_this).parent().parent(&quot;li&quot;).remove();
                          dialog.close();
                                                              }else {
                          dialog.close();
                                                                      showErrorView(&quot;服务器出错!&quot;);
                                                              }
                                                      }
                                              })
                }
            }
        ]
      });// end dialog
})// end unuse department

//点击部门显示职位相关信息
$(document).on(&quot;click&quot;, &quot;i.fa-list.js-to-show-positions&quot;, function(){
  var id = $(this).parent().data(&quot;id&quot;);
  $(&quot;div.branch_name&quot;).removeClass(&quot;active&quot;);
  var _this = this
  var department_show_teml = JST[&#39;settings/store_departments/show&#39;]
  $.ajax({
    url: &quot;/api/store_departments/&quot;+id,
    success: function(data){
      if(data.status){
        $(_this).parent().addClass(&quot;active&quot;);
        console.log(data);
        $(&quot;div.js-department-position-list&quot;).html(department_show_teml(data))
      }
    }
  })
});

//点击弹出新建职位的隐藏输入框
$(document).on(&quot;click&quot;, &quot;.fa-plus-square.js-click-to-new-position&quot;, function(){
  $(&quot;div.js-new-position-input&quot;).show();
})

// 点击职位隐藏框的保存
$(document).on(&quot;click&quot;, &quot;.fa-save.js-to-create-position&quot;, function(){
  var name = $(&quot;input.js-to-get-new-position-name&quot;).val();
  var position_tem = JST[&#39;settings/store_positions/item&#39;]
  var csrf = $(&quot;input#js-settings-zuzhi-index&quot;).val();
  var departmentId = $(this).data(&quot;department-id&quot;);
  $.ajax({
    url: &quot;/api/store_departments/&quot;+ departmentId +&quot;/store_positions&quot;,
    method: &quot;post&quot;,
    data: {name: name},
    headers: {
      &#39;X-CSRF-Token&#39;: csrf
    },
    success: function(data){
      if(data.status){
        $(&quot;div.js-new-position-input&quot;).hide();
        $(&quot;div.js-positions-list&quot;).append(position_tem(data.store_position))
      }else {
        showErrorView(data.message);
      }
    }
  }); // end to create position
})

// 取消创建部门
$(&quot;i.js-cancel-to-create-department&quot;).on(&quot;click&quot;, function(){
  $(&quot;li.new_department_tem&quot;).hide();
})

//点击名称修改部门
$(document).on(&quot;click&quot;, &#39;span.js-change-department-span-to-input&#39;, function(){
  $(this).parent().addClass(&quot;slide_up editing&quot;)
})

//取消编辑部门
$(document).on(&quot;click&quot;, &quot;i.js-cancel-to-update-department&quot;, function(){
  $(this).parent().removeClass(&quot;slide_up editing&quot;)
})

//点击保存编辑部门信息
$(document).on(&quot;click&quot;, &quot;i.js_update_department&quot;, function(){
  var id = $(this).parent().data(&quot;id&quot;);
  var name = $(this).siblings(&quot;input&quot;).val();
  var csrf = $(&quot;input#js-settings-zuzhi-index&quot;).val();
  var _this = this
  $.ajax({
    url: &quot;/api/store_departments/&quot;+id,
    method: &#39;put&#39;,
    headers: {
      &#39;X-CSRF-Token&#39;: csrf
    },
    data: {name: name},
    success: function(data){
      $(_this).parent().removeClass(&quot;slide_up editing&quot;);
      $(_this).siblings(&quot;span&quot;).text(name);
    }
  })
})

// 取消创建职位
$(document).on(&quot;click&quot;, &quot;i.js-cancel-to-create-position&quot;, function(){
  $(&quot;div.js-new-position-input&quot;).hide();
});

//点击修改更新职位
$(document).on(&quot;click&quot;, &quot;span.js-position-change-span-to-input&quot;, function(){
  $(this).parent().addClass(&quot;editing&quot;);
})

//取消更新职位信息
$(document).on(&quot;click&quot;, &quot;i.js-cancel-to-update-position&quot;, function(){
  $(this).parent().removeClass(&quot;editing&quot;);
})

//点击保存修改信息
$(document).on(&quot;click&quot;, &quot;i.js-to-update-position&quot;, function(){
  var _this = this
  var departmentId = $(this).data(&quot;department-id&quot;);
  var name = $(this).siblings(&quot;input&quot;).val();
  var id = $(this).parent().data(&quot;id&quot;);
  var csrf = $(&quot;input#js-settings-zuzhi-index&quot;).val();
  console.log(id);
  $.ajax({
    url: &quot;/api/store_departments/&quot;+ departmentId +&quot;/store_positions/&quot;+id,
    method: &quot;put&quot;,
    data: {name: name},
    headers: {
      &#39;X-CSRF-Token&#39;: csrf
    },
    success: function(data){
      if(data.status){
        $(_this).parent().removeClass(&quot;editing&quot;);
        $(_this).siblings(&quot;span&quot;).text(name);
      }
    }
  })
})</code></pre>

<p>})</p>

    </div>
  


  


  
  


  


  

  



  

    

    

    


    


    <!-- Methods -->
              </div>

    </div>
  </body>
</html>
